package com.jz.subclass.mapper;

import com.jz.legalplantclass.entity.LegalVO;
import com.jz.subclass.model.SubClassSelectVo;
import com.jz.subclass.model.SubClassVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by WISE on 2021/12/26.
 */
@Mapper
public interface SubClassMapper {


    List<SubClassVo> queryData(SubClassSelectVo subClassSelectVo);

    int queryCount(SubClassSelectVo subClassSelectVo);

    @Select("select * from subclass where code = #{code}")
    SubClassVo queryByCode(String code);

    @Select("select * from subclass where name = #{name}")
    SubClassVo queryByName(String name);

    @Insert("insert into subclass(name,code,remark,status,createTime,createName)" +
            "values(#{name},#{code},#{remark},#{status},#{createTime},#{createName})")
    void add(SubClassVo classVo);

    @Select("select * from subclass where id = #{id}")
    SubClassVo queryById(Integer id);

    @Update("update subclass set name = #{name},remark = #{remark},status = #{status},updateTime = #{updateTime},updateName = #{updateName},version = #{version}+1 where id = #{id} and version = #{version}")
    int update(SubClassVo classVo);

    @Update("update subclass set status = #{status},updaetTime = #{updateTime},updateName = #{updateName} where id = #{id}")
    void updateStatus(SubClassVo classVo);

    @Insert("insert into legalplantclass(legalPlantCode,legalPersonCode,legalPlantDec,enabled,createTime,createName) values(#{legalPlantCode},#{legalPersonCode},#{legalPlantDec},#{enabled},#{createTime},#{createName})")
    void add1(LegalVO legalVO);
}
